﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Jhong.FunMVC;

namespace Jhong.FunMVC.Test.Controllers
{
    using FunMVC;
    using System.IO;

    public class FileController : Controller
    {
        public ActionResult SingleFile()
        {
            var file = Request.Forms.Files[0];
            var savePath = Path.Combine(WebSiteRootPath, "Static", "File", Guid.NewGuid().ToString("N") + Path.GetExtension(file.FileName));
            file.SaveAs(savePath);

            if (Request.Forms.Files.Count() > 1)
            {
                file = Request.Forms.Files[1];
                savePath = Path.Combine(WebSiteRootPath, "Static", "File", Guid.NewGuid().ToString("N") + Path.GetExtension(file.FileName));
                file.SaveAs(savePath);
            }

            return null;
        }

        public ActionResult C()
        {
            var b1 = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 };
            var b2 = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
            //var x = MuilPartPostCollection.CheckBoundary(b1, 1, b2);
            return null;
        }
    }
}